use crate::args::AppArgs;
use crate::parse::split_into_args;
use clap::CommandFactory;
use clap::{FromArgMatches, Parser};
use sqlx::MySqlConnection;
use std::sync::Arc;
pub struct App {
    pool: Arc<MySqlConnection>,
}

impl App {
    pub fn new(pool: Arc<MySqlConnection>) -> Self {
        Self { pool: pool }
    }
    pub fn run(&self, input: &str) {
        println!("<<<running!");
        match AppArgs::try_parse_from(split_into_args(input)) {
            Ok(a) => {
                println!("args:{:?}", a);
            }
            Err(err) => {
                eprintln!("命令错误！具体怎么错的我不想告诉你", );
                println!("{}", AppArgs::command().render_help());
            }
        }
    }
}
